import { scanCodeTypeObj, tableColumns } from './data'

export function useColumns() {
  const getColumns = (column, record) => {
    if (column.dataIndex === 'scanCode') {
      return <span>{record.scanCode}</span>
    } else if (column.dataIndex === 'productName') {
      return <span>{record.productName}</span>
    } else if (column.dataIndex === 'scanCodeType') {
      let scanCodeTypeStr = ''
      scanCodeTypeObj.forEach(model => {
        if (model.value == record.scanCodeType) {
          scanCodeTypeStr = model.label
        }
      })
      return <span>{scanCodeTypeStr}</span>
    }
  }
  return {
    getColumns,
    tableColumns
  }
}
